package de.schnocklake.android.sap.crm.datamodel;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Item {
	private int id;
	private Product product;
	private double quantity;
	private String unit;
	private double netprice;

	public Item(int mId) {
		super();
		this.id = mId;
		this.product = null;
		this.quantity = 0;
		this.unit = null;
		this.netprice = 0;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		Product old = this.product;
		this.product = product;
		this.pcs.firePropertyChange("product", old, product);
	}

	public double getQuantity() {
		return quantity;
	}

	public void setQuantity(double quantity) {
		double old = this.quantity;
		this.quantity = quantity;
		this.pcs.firePropertyChange("quantity", old, quantity);
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		String old = this.unit;
		this.unit = unit;
		this.pcs.firePropertyChange("unit", old, unit);
	}

	public double getNetprice() {
		return netprice;
	}

	public void setNetprice(double netprice) {
		double old = this.netprice;
		this.netprice = netprice;
		this.pcs.firePropertyChange("netprice", old, netprice);
	}

	// Beans stuff --- property change implementation

	private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		this.pcs.addPropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		this.pcs.removePropertyChangeListener(listener);
	}

}
